'use strict';
angular.module('clientApp')
.value('panelURL', 'http://127.0.0.1:8080/M2TIIL_AERO_2015')
.factory('panelAPI', function($http, panelURL) {
    return {
        add : function(panel) {
            return $http({
                url : panelURL + '/addPanel.htm?name=' + panel.name + '&hourOfDisplay=' + panel.hourOfDisplay + '&idxFlight=' + panel.idFlight,
                method : 'POST',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        },
        remove : function(id){
        	return $http({
        		url : panelURL + '/removePanel.htm?idPanel=' + id,
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        },
        modify : function(panel){
        	return $http({
        		url : panelURL + '/modifiyPanel.htm?idxPanel=' + panel.id + '&name=' + panel.name + '&hourOfDisplay=' + panel.hourOfDisplay + '&idxFlight=' + panel.idFlight,
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        },
        get : function(id){
        	return $http({
        		url : panelURL + '/getPanel.htm?idxPanel=' + id,
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        },
        list : function(){
        	return $http({
        		url : panelURL + 'getPanels.htm',
        		method : 'GET',
        		headers : {
        			'Content-Type' : 'application/json'
        		}
        	});
        }
    };
    
});